<!DOCTYPE html>
<html>
 <head>
  <title>js面向对象</title>
  <meta charset="utf-8">
 </head>

 <body>
  <script>
	//工程模式
	function createObject(user,pwd){
		var obj = new Object()
		obj.user = user
		obj.pwd = pwd
		obj.print = function (){
			return this.user+this.pwd
		}
		return obj
	}
	var o1 = createObject('li',123)
	alert(o1)
	alert(o1.print())

	//构造函数
	function User(user, pwd){
		this.user = user
		this.pwd = pwd
		this.print = function () {
			return this.user + this. pwd
		}
	}
	var u = new User('zhan', 456)
	alert(u)
	alert(u.print())

  </script>
 </body>
</html>
